# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libwmf

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.8.4
pkgrel=2
pkgdesc="Library for Converting Metafile Images (mingw-w64)"
arch=('any')
url="http://wvWare.sourceforge.net"
license=("GPL" "LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "libtool"
    )
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
    "${MINGW_PACKAGE_PREFIX}-freetype"
    "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
    "${MINGW_PACKAGE_PREFIX}-gtk2"
    "${MINGW_PACKAGE_PREFIX}-libjpeg"
    "${MINGW_PACKAGE_PREFIX}-libpng"
    "${MINGW_PACKAGE_PREFIX}-libxml2"
    "${MINGW_PACKAGE_PREFIX}-zlib"
    )
options=('strip' 'staticlibs')
source=(http://downloads.sourceforge.net/wvware/libwmf-${pkgver}.tar.gz
    libwmf-0.2.8.4-libpng.patch)
md5sums=('d1177739bf1ceb07f57421f0cee191e0'
         '57e26e68cbaaeb3ffd6a8a84f08c3bfd')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/libwmf-0.2.8.4-libpng.patch
  libtoolize --force --copy --install
  autoreconf -f -i
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --disable-static \
    --with-libxml2 \
    --without-x

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm "${pkgdir}${MINGW_PREFIX}"/lib/gtk-2.0/2.*/loaders/*.dll.a
}
